package main.java.indi.zyj.coderecord;

public class FindMaxForm {

    public int findMaxForm(String[] strs, int m, int n) {

        // m个0，n个1的需要最多str组成的个数
        int[][] dp = new int[m + 1][n + 1];

        for (String str : strs) {
            char[] charArray = str.toCharArray();

            int zeroSum = 0, oneSum = 0;
            for (char c : charArray) {
                if (c == '0') {
                    zeroSum++;
                } else {
                    oneSum++;
                }
            }

            for (int i = m; i >= zeroSum; i--) {
                for (int j = n; j >= oneSum ; j--) {
                    dp[i][j] = Math.max(dp[i][j], dp[i - zeroSum][j - oneSum] + 1);
                }
            }

        }

        return dp[m][n];


    }

}
